﻿
Imports System.Text
Imports Microsoft.VisualStudio.Utilities
Imports System.IO
Imports System.Xml.Serialization
Imports System.Xml

Namespace VsSpeakerCompanion
	''' <summary>
	''' Manages settings that could be shared between different instances of the Speaker
	''' </summary>
	Public Class SharedSettings
		Inherits Settings
        Private Const DefaultSettingsPath = "Settings-shared.xml"

		''' <summary>
		''' Creates a new instance of <see cref="SharedSettings"/>
		''' </summary>
		Public Sub New()
			MyBase.New(DefaultSettingsPath)
		End Sub

		''' <summary>
		''' Updates the setting value for the specified key
		''' </summary>
		''' <param name="key"></param>
		''' <param name="value"></param>
		Public Overrides Sub Update(ByVal key As String, ByVal value As Object)
			Load()
			MyBase.Update(key, value)
			Save()
		End Sub

		''' <summary>
		''' Gets the setting value for the specified key
		''' </summary>
		''' <typeparam name="T"></typeparam>
		''' <param name="key"></param>
		''' <returns></returns>
		Public Overrides Function [Get](Of T)(ByVal key As String) As T
			Load()
			Return MyBase.Get(Of T)(key)
		End Function
	End Class
End Namespace